<template>
  <div class="silder-box">
    <i class="progress"></i>
    <i class="point" style="let:-1px" @click="zeroClick()" :class="value2>=0?'active':''"></i>
    <i
      class="point point1"
      style="left:25%;transform:translateX(-20%)"
      @click="onceClick()"
      :class="value2>=25 && !isActiveInput ?'active':''"
    ></i>
    <i
      class="point"
      style="left:50%;transform:translateX(-40%)"
      @click="twoClick()"
      :class="value2>=50 && !isActiveInput ?'active':''"
    ></i>

    <i
      class="point"
      style="left:75%;transform:translateX(-50%)"
      @click="threeClick()"
      :class="value2>=75 && !isActiveInput ?'active':''"
    ></i>
    <i class="point" style="right:0" @click="fiveClick()"></i>
    <div class="point-side" :style="{left:value}">
      <i class="isCkeck"></i>
    </div>
    <i class="drag-track" :style="{backgroundSize:value2+'%,10%'}"></i>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: "-1px",
      value2: 0
    };
  },
  methods: {
    zeroClick() {
      this.value = "-1px";
      this.value2 = 0;
      this.$emit("change", (this.value2 * 1) / 100);
    },
    onceClick() {
      this.value = "24%";
      this.value2 = 25;
      this.$emit("change", (this.value2 * 1) / 100);
    },
    twoClick() {
      this.value = "47%";
      this.value2 = 50;
      this.$emit("change", (this.value2 * 1) / 100);
    },
    threeClick() {
      this.value = "72%";
      this.value2 = 75;
      this.$emit("change", (this.value2 * 1) / 100);
    },
    fiveClick() {
      this.value = "95%";
      this.value2 = 100;
      this.$emit("change", (this.value2 * 1) / 100);
    }
  },
  props: ["isActiveInput"],
  watch: {
    isActiveInput: function() {
      if (this.isActiveInput) {
        this.value = "-1px";
        this.value2 = 0;
      }
    }
  },
  created() {},
  mounted() {}
};
</script>
<style scoped>
.silder-box {
  height: 16px;
  position: relative;
  width: calc(100% - 6px);
  margin-left: 3px;
}
.progress {
  background-color: rgba(228, 231, 236, 0.2);
  position: absolute;
  width: 100%;
  top: 8px;
  height: 2px;
  font-style: normal;
  box-sizing: border-box;
}
.point {
  background-color: rgba(136, 136, 138,0.9);
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  top: 3px;
  transition: transform 0.2s, -webkit-transform 0.2s;
  cursor: pointer;
  z-index: 3;
}
.point:hover,
.point1:hover {
  transform: scale(1.5);
  -moz-transform: scale(1.5);
  -webkit-transform: scale(1.5);
}
.point-side {
  width: 16px;
  height: 16px;
  position: absolute;
  border-radius: 50%;
  top: 2px;
  border: solid 1px #52bdb7;
  z-index: 4;
}
.isCkeck {
  position: absolute;
  border: 2.5px solid #fff;
  background-color: #52bdb7;
  width: 15px;
  height: 15px;
  width: 100%;
  height: 100%;
  transition: transform 0.2s, -webkit-transform 0.2s;
  cursor: pointer;
  z-index: 3;
  border-radius: 50%;
}
.isCkeck:hover {
  box-shadow: 0 0 0 6px rgba(18, 184, 134, 0.2);
}
.drag-track {
  background-image: linear-gradient(#52bdb7, #52bdb7);
  top: 9px;
  height: 2px;
  font-style: normal;
  box-sizing: border-box;
  left: 0;
  right: 0;
  position: absolute;
  margin-left: 8px;
  background-position: 0;
  background-repeat: no-repeat;
  z-index: 1;
  cursor: pointer;
}
.active {
  background-color: #52bdb7;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  z-index: 3;
  position: absolute;
  top:4px;
}
</style>
